<?php

define('INIT_TIMESTAMP', microtime());

/**
 * This file just generates the oAuth token and then
 * redirects the browser to Twitter for authentication
 *
 * No actual page rendering will be taking place.
 */
include '../!inc.php';


try {

    ini_set('session.use_only_cookies', true);
    ini_set('session.use_trans_sid', false);
    if (true !== session_start()) {
        throw new StudyBuddy\Exception('session_start_error');
    }

    include($StudyBuddyClasses . 'Controllers' . DIRECTORY_SEPARATOR . 'Logintwitter.php');

    $o = new \StudyBuddy\Controllers\Logintwitter($oRegistry);
    header('Content-Type: text/html; charset=utf-8');
    echo $o->getResult();
    fastcgi_finish_request();
} catch (\Exception $e) {

    try {
        echo \StudyBuddy\Responder::makeErrorPage('<strong>Error:</strong> ' . \StudyBuddy\Exception::formatException($e));
    } catch (Exception $e2) {
        echo \StudyBuddy\Responder::makeErrorPage('<strong>Exception:</strong> ' . $e2->getMessage() . "\nIn file:" . $e2->getFile() . "\nLine: " . $e2->getLine());
    }
}
